Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Creating Groups

You create a new light group, for example, by calling the Q3LightGroup_New function. If there is sufficient memory to create the group, Q3LightGroup_New returns to your application a reference to a group object, which you pass to other group routines. The new group is initially empty, and you add objects to the group by calling QuickDraw 3D routines (such as Q3Group_AddObject ). When an object is added to a group, its reference count is incremented. (QuickDraw 3D uses the reference count to ensure that an object is not prematurely disposed.) If you don't want to maintain references to all the objects inside a group, you can use the technique illustrated in Listing 1 .

Listing 1 Creating a group

myGroup = Q3LightGroup_New();
myLight = Q3SpotLight_New(mySpotLightData);
Q3Group_AddObject(myGroup, myLight);
Q3Object_Dispose(myLight);

By calling Q3Object_Dispose , you decrement the light's reference count once it's been added to the light group. When the group itself is later disposed of, QuickDraw 3D decrements the light's reference count, which may cause it also to be disposed of.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |